bitkeeper revision 1.1159.61.1 (412f59d0QmtgAMJvSE3LvKxxaMUfZg)
authorcl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>
Fri, 27 Aug 2004 15:57:04 +0000 (15:57 +0000)
committercl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>
Fri, 27 Aug 2004 15:57:04 +0000 (15:57 +0000)
Call domain_crash() instead of BUG() if something goes wrong with writabel pagetables.

xen/arch/x86/memory.c
xen/common/domain.c

index 778edf0ee13c15d60c8412271734e42b59320a43..f6a56577986c9252096140d41f871db347010140 100644 (file)
@@ -1488,8 +1488,10 @@ void ptwr_reconnect_disconnected(unsigned long addr)
                  addr, ptwr_info[cpu].disconnected << L2_PAGETABLE_SHIFT));
     pl2e = &linear_l2_table[ptwr_info[cpu].disconnected];
 
-    if (__get_user(pte, writable_pte))
-        BUG();
+    if (__get_user(pte, writable_pte)) {
+       MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
+       domain_crash();
+    }
     pfn = pte >> PAGE_SHIFT;
     page = &frame_table[pfn];
 
@@ -1512,8 +1514,10 @@ void ptwr_reconnect_disconnected(unsigned long addr)
             continue;
         if (unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT))
             put_page_from_l1e(ol1e, current);
-        if (unlikely(!get_page_from_l1e(nl1e, current)))
-            BUG();
+        if (unlikely(!get_page_from_l1e(nl1e, current))) {
+           MEM_LOG("ptwr: Could not re-validate l1 page\n");
+           domain_crash();
+       }
     }
     unmap_domain_mem(pl1e);
     update_l2e(pl2e, *pl2e, nl2e);
@@ -1525,13 +1529,17 @@ void ptwr_reconnect_disconnected(unsigned long addr)
                  frame_table[pfn].u.inuse.domain->domain));
     ptwr_info[cpu].disconnected = ENTRIES_PER_L2_PAGETABLE;
     /* make pt page write protected */
-    if (__get_user(pte, writable_pte))
-        BUG();
+    if (__get_user(pte, writable_pte)) {
+       MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
+       domain_crash();
+    }
     PTWR_PRINTK(("[A] writable_l1 at %p is %08lx\n",
                  writable_pte, pte));
     pte &= ~_PAGE_RW;
-    if (__put_user(pte, writable_pte))
-        BUG();
+    if (__put_user(pte, writable_pte)) {
+       MEM_LOG("ptwr: Could not update pte at %p\n", writable_pte);
+       domain_crash();
+    }
     __flush_tlb_one(ptwr_info[cpu].writable_l1);
     PTWR_PRINTK(("[A] writable_l1 at %p now %08lx\n",
                  writable_pte, pte));
@@ -1564,8 +1572,10 @@ void ptwr_flush_inactive(void)
     for (idx = 0; idx < ptwr_info[cpu].writable_idx; idx++) {
         unsigned long *writable_pte = (unsigned long *)&linear_pg_table
             [ptwr_info[cpu].writables[idx]>>PAGE_SHIFT];
-        if (__get_user(pte, writable_pte))
-            BUG();
+        if (__get_user(pte, writable_pte)) {
+           MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
+           domain_crash();
+       }
         pfn = pte >> PAGE_SHIFT;
         page = &frame_table[pfn];
         PTWR_PRINTK(("[I] alloc l1 page %p\n", page));
@@ -1579,8 +1589,10 @@ void ptwr_flush_inactive(void)
                 continue;
             if (unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT))
                 put_page_from_l1e(ol1e, current);
-            if (unlikely(!get_page_from_l1e(nl1e, current)))
-                BUG();
+            if (unlikely(!get_page_from_l1e(nl1e, current))) {
+               MEM_LOG("ptwr: Could not re-validate l1 page\n");
+               domain_crash();
+           }
         }
         unmap_domain_mem(pl1e);
 
@@ -1588,8 +1600,10 @@ void ptwr_flush_inactive(void)
         PTWR_PRINTK(("[I] writable_l1 at %p is %08lx\n",
                      writable_pte, pte));
         pte &= ~_PAGE_RW;
-        if (__put_user(pte, writable_pte))
-            BUG();
+        if (__put_user(pte, writable_pte)) {
+           MEM_LOG("ptwr: Could not update pte at %p\n", writable_pte);
+           domain_crash();
+       }
         __flush_tlb_one(ptwr_info[cpu].writables[idx]);
         PTWR_PRINTK(("[I] writable_l1 at %p now %08lx\n",
                      writable_pte, pte));
@@ -1690,8 +1704,11 @@ int ptwr_do_page_fault(unsigned long addr)
             PTWR_PRINTK(("update %p pte to %08lx\n",
                          &linear_pg_table[addr>>PAGE_SHIFT], pte));
             if ( __put_user(pte, (unsigned long *)
-                           &linear_pg_table[addr>>PAGE_SHIFT]) )
-                BUG();
+                           &linear_pg_table[addr>>PAGE_SHIFT]) ) {
+               MEM_LOG("ptwr: Could not update pte at %p\n", (unsigned long *)
+                       &linear_pg_table[addr>>PAGE_SHIFT]);
+               domain_crash();
+           }
             return 1;
         }
     }
@@ -1713,8 +1730,11 @@ static void ptwr_init_backpointers(void)
 
         page = &frame_table[pde >> PAGE_SHIFT];
         /* assert that page is an l1_page_table   XXXcl maybe l2? */
-        if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table )
-            BUG();
+        if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table ) {
+           MEM_LOG("ptwr: Inconsistent pagetable: pde %x is not an l1 page\n",
+                   pde >> PAGE_SHIFT);
+           domain_crash();
+       }
         page->u.inuse.type_info &= ~PGT_va_mask;
         page->u.inuse.type_info |= va_idx << PGT_va_shift;
     }
@@ -1739,8 +1759,10 @@ void ptwr_status(void)
         unsigned long *writable_pte = (unsigned long *)&linear_pg_table
             [ptwr_info[cpu].writables[i]>>PAGE_SHIFT];
 
-        if ( __get_user(pte, writable_pte) )
-            BUG();
+        if ( __get_user(pte, writable_pte) ) {
+           MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
+           domain_crash();
+       }
 
         pfn = pte >> PAGE_SHIFT;
         page = &frame_table[pfn];
@@ -1757,8 +1779,11 @@ void ptwr_status(void)
            ptwr_info[cpu].disconnected << L2_PAGETABLE_SHIFT);
     pl2e = &linear_l2_table[ptwr_info[cpu].disconnected];
 
-    if ( __get_user(pte, (unsigned long *)ptwr_info[cpu].writable_l1) )
-        BUG();
+    if ( __get_user(pte, (unsigned long *)ptwr_info[cpu].writable_l1) ) {
+       MEM_LOG("ptwr: Could not read pte at %p\n", (unsigned long *)
+               ptwr_info[cpu].writable_l1);
+       domain_crash();
+    }
     pfn = pte >> PAGE_SHIFT;
     page = &frame_table[pfn];
 
index 55621847d029096a0f42cb123eab0a6bb88ae039..314f875511b075b51668ed8a51f3f6639f4242d9 100644 (file)
@@ -152,6 +152,9 @@ void domain_crash(void)
 {
     struct domain *d;
 
+    if (current->domain == 0)
+       BUG();
+
     set_bit(DF_CRASHED, &current->flags);
 
     d = find_domain_by_id(0);